package com.gin.kotlin.no_gay_alliance.adapter.me

import android.content.Context
import com.gin.kotlin.no_gay_alliance.activity.UserCenterActivity
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingRecyclerViewAdapter
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemBlockConfigBinding

class BlockConfigAdapter(context: Context, handler: MyHandler) :
    AbstractBindingRecyclerViewAdapter<ItemBlockConfigBinding, String>(context, handler, false) {
    override fun onBindViewHolder(holder: ViewHolder<ItemBlockConfigBinding>, position: Int, b: ItemBlockConfigBinding, dataModel: String) {
        b.tvUsername.text = dataModel
        b.tvUsername.tag = dataModel
        b.tvUsername.setOnClickListener{ UserCenterActivity.startActivity(context,username = it.tag.toString()) }

        b.ivDelete.tag  = dataModel
        b.ivDelete.setOnClickListener{
            val index = data.indexOf(it.tag.toString())
            if (index>=0) removeData(index)
        }

    }
}